package org.scuecsz.view.utils;

import java.io.Serializable;

public class ImageData implements Serializable {

    private String name;
    private String mime;
    private long length;
    private byte[] data;
    private String extension;

    public byte[] getData() {
        return data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }

    public long getLength() {
        return length;
    }

    public void setLength(long length) {
        this.length = length;
    }

    public String getMime() {
        return mime;
    }

    public void setMime(String mime) {
        this.mime = mime;
    }

    public String getName() {
        return name;
    }

    public void setName(String Name) {
        if (null != Name) {
            int extDot = Name.lastIndexOf('.');
            if (extDot > 0) {
                extension = Name.substring(extDot + 1);
            }
        }
        if ("bmp".equals(extension)) {
            mime = "image/bmp";
        } else if ("jpg".equals(extension)) {
            mime = "image/jpeg";
        } else if ("gif".equals(extension)) {
            mime = "image/gif";
        } else if ("png".equals(extension)) {
            mime = "image/png";
        } else {
            mime = "image/unknown";
        }
        this.name = Name;
    }

    public String getExtension() {
        return extension;
    }

    public void setExtension(String extension) {
        this.extension = extension;
    }

    public void clear() {
       name=null;
       mime=null;
       length=0;
       data=null;
       extension=null;
    }
}
